﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="BillModule.cs" company="Concept Architecture">
//   (c) 2010 Muhammad Umer Farooq
// </copyright>
// <summary>
//   Defines the <seealso cref="BillModule" /> type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Hisaab.Client.Modules.Core.Bill
{
    using Hisaab.Client.Common;
    using Hisaab.Client.Modules.Core.Bill.View;

    using Microsoft.Practices.Prism.Modularity;
    using Microsoft.Practices.Prism.Regions;
    using Microsoft.Practices.ServiceLocation;
    using Microsoft.Practices.Unity;

    /// <summary>
    /// Defines the <seealso cref="BillModule"/> type.
    /// </summary>
    public class BillModule : IModule
    {
        /// <summary>
        /// Member variable BillViewName
        /// </summary>
        public static string BillViewName = "Bill";

        /// <summary>
        /// Member variable BillsTabName
        /// </summary>
        public const string BillsTabName = "BillsTab";

        /// <summary>
        /// Member variable ModuleName
        /// </summary>
        public const string ModuleName = "BillModule";

        /// <summary>
        /// Member variable BillsViewName
        /// </summary>
        public const string BillsViewName = "Bills";

        /// <summary>
        /// Member variable BillEditorName
        /// </summary>
        public const string BillEditorName = "BillEditor";

        /// <summary>
        /// Member variable BillPaymentEditorName
        /// </summary>
        public const string BillPaymentEditorName = "BillPaymentEditor";

        /// <summary>
        /// Initializes this instance.
        /// </summary>
        public void Initialize()
        {
            var regionManager = ServiceLocator.Current.GetInstance<IRegionManager>();
            regionManager.RegisterViewWithRegion(Regions.HomeAddMediumGroup, typeof(BillAddButton));
            regionManager.RegisterViewWithRegion(Regions.HomeListGroup, typeof(BillViewButton));
            regionManager.RegisterViewWithRegion(Regions.HomeAddGroup, typeof(BillPaymentButton));
            regionManager.RegisterViewWithRegion(Regions.NavigationRegion, typeof(BillNavigation));
            regionManager.RegisterViewWithRegion(Regions.RibbonRegion, typeof(BillsTab));

            var container = ServiceLocator.Current.GetInstance<IUnityContainer>();
            container.RegisterType<object, Bills>(BillsViewName);
            container.RegisterType<object, BillEditor>(BillEditorName);
            container.RegisterType<object, BillPaymentEditor>(BillPaymentEditorName);
            container.RegisterType<object, BillsTab>(BillsTabName);
            container.RegisterType<object, BillView>(BillViewName);
        }
    }
}